package com.woniuxy.java106crm.controller;

import com.woniuxy.java106crm.annotation.RequireMethod;
import com.woniuxy.java106crm.entity.LogManage;
import com.woniuxy.java106crm.entity.Lost;
import com.woniuxy.java106crm.request.ResPage;
import com.woniuxy.java106crm.request.ResponseResult;
import com.woniuxy.java106crm.service.LogManageService;
import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@Api(tags = "操作日志管理模块API文档")
@RestController
@RequestMapping("/logManage")
public class LogManageController {

    @Resource
    private LogManageService logManageService;

    /**
     * 查询日志信息
     * @param page
     * @param size
     * @param logManage
     * @return
     */
    @RequireMethod("查询日志信息")
    @GetMapping("/queryCondition/{page}/{size}")
    public ResponseResult<ResPage<List<LogManage>>> queryCondition(
            @PathVariable("page")Integer page, @PathVariable("size") Integer size, LogManage logManage){
        ResPage<List<LogManage>> resPage = logManageService.queryCondition(page,size,logManage);
        return new ResponseResult<>(ResponseResult.OK,resPage);
    }

    /**
     * 删除操作日志
     * @param id
     * @return
     */
    @RequireMethod("删除操作日志")
    @DeleteMapping("/deleteById/{id}")
    public ResponseResult<Boolean> deleteById(@PathVariable("id") Integer id){
        return new ResponseResult<>(ResponseResult.OK,logManageService.deleteById(id));
    }

    /**
     * 批量删除操作日志
     * @param ids
     * @return
     */
    @RequireMethod("批量删除操作日志")
    @DeleteMapping("/batchedDelByIds/{ids}")
    public ResponseResult<Boolean> batchedDelByIds(@PathVariable("ids") String ids){
        return new ResponseResult<>(ResponseResult.OK,logManageService.batchedDelByIds(ids));
    }
}
